package edu.caltech.android.earthquake;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.location.Location;

/**
 * Class to represent an Earthquake. 
 *  
 * Portions of this code from Professional Android 2 Application Development,
 * ISBN: 978-0-470-56552-0, copyright Wiley Publishing Inc: 2010, by Reto Meier,
 * published under the Wrox imprint are used by permission of Wiley Publishing,
 * Inc. All rights reserved. This book and the Wrox code are available for
 * purchase or download at www.wrox.com
 * 
 */
public class Quake {
	private Date date;
	private String details;
	private Location location;
	private double magnitude;
	private String link;

	public Date getDate() {
		return date;
	}

	public String getDetails() {
		return details;
	}

	/**
	 * Location, in degrees latitude and longitude
	 * 
	 * @return
	 */
	public Location getLocation() {
		return location;
	}

	public double getMagnitude() {
		return magnitude;
	}

	/**
	 * Web link for more information about this quake
	 * 
	 * @return
	 */
	public String getLink() {
		return link;
	}

	/**
	 * 
	 * @param _d
	 * @param _det
	 * @param _loc
	 *            Latitude and Longitude are in degrees.
	 * @param _mag
	 * @param _link
	 */
	public Quake(Date _d, String _det, Location _loc, double _mag, String _link) {
		date = _d;
		details = _det;
		location = _loc;
		magnitude = _mag;
		link = _link;
	}

	@Override
	public String toString() {
		SimpleDateFormat sdf = new SimpleDateFormat("HH.mm");
		String dateString = sdf.format(date);
		return dateString + ": " + magnitude + " " + details;
	}
}
